package com.example.sky20.servlet;

import com.example.sky20.Bean.NoticeBean;
import com.example.sky20.dao.NoticeDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/noticeDetail.html")
public class NoticeDetailSevlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String NoticeID = req.getParameter("NoticeID");
        int noticeID = Integer.parseInt(NoticeID);
        NoticeBean notice = (new NoticeDao()).getNoticeById(noticeID);
        req.setAttribute("title", notice.getNoticeTitle());
        req.setAttribute("content" , notice.getNoticeContent());
        req.getRequestDispatcher("noticeFrontDetail.jsp").forward(req, resp);
    }
}